<%@ Page Language="C#" MasterPageFile="~/MasterPages/Grey/Grey.Master" AutoEventWireup="true"
    CodeBehind="Reviews.aspx.cs" Inherits="mmq.Reviews" Title="<%$ Resources:GlobalResource,ReviewsPageTitle %>"
    Theme="Grey" %>

<%@ Import Namespace="System.Data" %>
<%@ Register Src="UserControls/TreeEditor.ascx" TagName="TreeEditor" TagPrefix="uc2" %>
<%@ Register Src="UserControls/HeaderMenu.ascx" TagName="HeaderMenu" TagPrefix="uc1" %>
<asp:Content ID="Content2" ContentPlaceHolderID="Left" runat="server">
    <asp:ScriptManagerProxy runat="server" ID="ScriptManagerProxy1" />
    <asp:Repeater ID="MainPage" runat="server">
        <HeaderTemplate>
            <table width="100%" id="categorytable">
                <tr>
                    <td>
                        <h2>
                            <asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:GlobalResource,Reviews%>" /></h2>
                    </td>
                </tr>
        </HeaderTemplate>
        <SeparatorTemplate>
            <tr>
                <td>
                    <asp:Image SkinID="SeparatorImage" runat="server" ID="Separator" Style="display: block;
                        margin-left: auto; margin-right: auto" />
                </td>
            </tr>
        </SeparatorTemplate>
        <ItemTemplate>
            <tr>
                <td class="helpBod">
                    <h3>
                        <%# DataBinder.Eval(Container.DataItem, "title")%>
                    </h3>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Repeater ID="rptr_Detailes" runat="server" DataSource='<%# ((DataRowView)Container.DataItem).Row.GetChildRows("ParentChild") %>'
                        OnItemCommand="reviews_ItemCommand" OnItemDataBound="reviews_ItemDataBound">
                        <HeaderTemplate>
                            <table width="100%" class="reviewtable">
                        </HeaderTemplate>
                        <ItemTemplate>
                            <tr>
                                <td class="helpHed">
                                    <asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:GlobalResource,Reviewer%>" />
                                    :
                                    <%# DataBinder.Eval(Container.DataItem, "[\"UserName\"]")%>
                                </td>
                                <td class="helpHedR">
                                    <asp:Literal ID="Literal2" runat="server" Text="<%$ Resources:GlobalResource,CreatedDate%>" />
                                    :
                                    <%# DataBinder.Eval(Container.DataItem, "[\"CreatedDate\"]")%>
                                    <asp:LinkButton ID="lb_remove" runat="server" CommandName="Delete" OnClientClick="return confirm('Are you sure you want to delete this record?');"
                                        Text="<%$ Resources:GlobalResource,Delete%>" />
                                </td>
                            </tr>
                            <tr>
                                <td class="helpT" colspan="2">
                                    <h3>
                                        <%# DataBinder.Eval(Container.DataItem, "[\"Title\"]")%>
                                    </h3>
                                </td>
                            </tr>
                            <tr>
                                <td align="left" colspan="2">
                                    <%# DataBinder.Eval(Container.DataItem, "[\"Review\"]")%>
                                </td>
                            </tr>
                        </ItemTemplate>
                        <FooterTemplate>
                            </table>
                        </FooterTemplate>
                    </asp:Repeater>
                </td>
            </tr>
        </ItemTemplate>
        <FooterTemplate>
            </table>
        </FooterTemplate>
    </asp:Repeater>
    <div style="float: left">
        <asp:Repeater ID="rptrPage" runat="server" OnItemCommand="reviews_ItemCommand">
            <HeaderTemplate>
                <table>
                    <tr>
            </HeaderTemplate>
            <ItemTemplate>
                <td><asp:LinkButton ID="lnkBtnPage" runat="server" CommandName="SelectPage" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"pagecount") %>' Text='<%# DataBinder.Eval(Container.DataItem,"pagecount") %>'></asp:LinkButton>
                </td>
            </ItemTemplate>
            <FooterTemplate>
                </tr> </table>
            </FooterTemplate>
        </asp:Repeater>
    </div>
    <div style="float: right">
        <asp:LinkButton runat="server" ID="lnkBtn_NewReview" Text="<%$ Resources:GlobalResource,NewReview %>" />
    </div>

    <script language="javascript" type="text/javascript">
        function OnNodeClick(selected_node_value, selected_node_text, literalctrl, hf_selectedValue, btn_ok) {
            document.getElementById(literalctrl).innerText = " : " + selected_node_text;
            document.getElementById(btn_ok).style.visibility = "visible";
            document.getElementById(hf_selectedValue).value = selected_node_value;
        }
        function GetHtmlEditor() {
            return $find('<%= HtmlEditor1.ClientID %>');
        }

    </script>

    <asp:Panel ID="popup_panel" runat="server" Style="display: none" CssClass="modalPopup"
        Width="700px">
        <div class="pcol2">
            <div class="pleft">
                <p>
                    <asp:Label ID="label1" runat="server" Text="<%$ Resources:GlobalResource,Comment_SelectCategory %>" />
                </p>
                <uc2:TreeEditor ID="TreeEditor2" runat="server" />
            </div>
            <div class="pright">
                <p>
                    <asp:Label ID="label2" runat="server" Text="<%$ Resources:GlobalResource,Comment_CategorySelected %>" />
                    <asp:Label ID="label_category" runat="server" />
                    <asp:HiddenField ID="hf_selectedValue" runat="server" />
                </p>
                <table border="0">
                    <tr>
                        <td>
                            <asp:Label Text="<%$ Resources:GlobalResource,Title %>" runat="server" ID="lblTitle" />
                            <asp:TextBox runat="server" ID="txtBoxTitle" Columns="50" />
                        </td>
                        <td>
                            <ajaxControlToolkit:Rating ID="ajaxRate" runat="server" CurrentRating="5" MaxRating="5"
                                StarCssClass="ratingStar" WaitingStarCssClass="savedRatingStar" FilledStarCssClass="filledRatingStar"
                                EmptyStarCssClass="emptyRatingStar" />
                        </td>
                    </tr>
                </table>
                <htmlEditor:HtmlEditor ID="HtmlEditor1" runat="server" />
                <asp:LinkButton runat="server" CausesValidation="true" ID="btn_Ok" Text="<%$ Resources:GlobalResource,Submit %>"
                    Style="visibility: hidden" OnClick="btn_Ok_Click" />
                <asp:LinkButton runat="server" ID="btn_Cancel" Text="<%$ Resources:GlobalResource,Return %>" />
            </div>
        </div>
    </asp:Panel>
    <ajaxControlToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="lnkBtn_NewReview"
        PopupControlID="popup_panel" CancelControlID="btn_Cancel" BackgroundCssClass="modalBackground">
    </ajaxControlToolkit:ModalPopupExtender>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="Right" runat="server">
    <uc2:TreeEditor ID="TreeEditor1" runat="server" OnSelectedNodeChanged="categorySelected" />
</asp:Content>
<asp:Content ContentPlaceHolderID="navigation" runat="server">
    <uc1:HeaderMenu ID="HeaderMenu1" runat="server" SelectedTab="Reviews" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="BottomLeft" runat="server">
    <h2>
        <asp:Literal ID="literal1" runat="server" Text="<%$ Resources:GlobalResource,HotReviews %>" />
    </h2>
    <asp:Repeater DataSourceID="SqlDSReviews" runat="server" ID="rptr_News" OnItemCommand="reviews_ItemCommand">
        <HeaderTemplate>
            <ul class="block">
        </HeaderTemplate>
        <ItemTemplate>
            <li>
                <%--<a href='<%# "Reviews.aspx?QS_ReviewID="+DataBinder.Eval(Container.DataItem, "CategoryID") %>'>--%>
                <asp:LinkButton CommandName="Select" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "CategoryID") %>'
                    runat="server">
                <span>
                    <%# DataBinder.Eval(Container.DataItem, "Title")%>
                </span><em>
                    <%# DataBinder.Eval(Container.DataItem, "Description").ToString()%></em></asp:LinkButton><%--</a>--%></li>
        </ItemTemplate>
        <FooterTemplate>
            </ul>
        </FooterTemplate>
    </asp:Repeater>
    <asp:SqlDataSource ID="SqlDSReviews" runat="server" ConnectionString="<%$ ConnectionStrings:AC_DBConnectionString %>"
        SelectCommandType="StoredProcedure" SelectCommand="AC_GetAllHotReviews">
        <SelectParameters>
            <asp:Parameter DefaultValue="5" Name="CountNum" Type="Int32" />
            <asp:ProfileParameter DefaultValue="en-US" Name="LanguageKey" PropertyName="PreferredCulture"
                Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>
